package com.ryan.sbnote.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;

public class DbHelper extends SQLiteOpenHelper{

	public DbHelper(Context context) {
		super(context, "sbnote", null, 1);
	}

	public static class Note{
		public static final Uri CONTENT_URI = Uri.parse("content://com.ryan.sbnote.provider/note");
		public static final String USER="user";
		public static final String TITLE="title";
		public static final String DATA="data";
		public static final String CREATE="create_time";
		public static final String VER="ver";
		public static final String SYN="syn";
	}
	public static class Img{
		public static final Uri CONTENT_URI = Uri.parse("content://com.ryan.sbnote.provider/img");
		public static final String NOTE="note";
		public static final String KEY="key";
		public static final String IMG="img";
	}
	
	String tableNote = "CREATE TABLE IF NOT EXISTS note(_id INTEGER PRIMARY KEY,user INTEGER,title TEXT,data TEXT,create_time INTEGER,ver INTEGER,syn INTEGER);";
	String tableImg = "CREATE TABLE IF NOT EXISTS img(_id INTEGER PRIMARY KEY,note INTEGER,key TEXT, img BLOB);";
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(tableNote);
		db.execSQL(tableImg);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		onCreate(db);
	}

}
